const mutations = {
  updateIntoPayList (state, obj) {
    const i = obj.i
    for (let k = 0; k < i.length; k++) {
      for (let j = 0; j < state.tableData.length; j++) {
        if (state.tableData[j].id === i[k]) {
          state.tableData[j].status = 'true'
          state.tableData[j].addr = obj.addr
          state.tableData[j].payDate = new Date().getFullYear().toString() + '-' + (new Date().getMonth() + 1).toString() + '-' + new Date().getDate().toString()
          break
        }
      }
    }
  },
  changeCurrentList (state, payload) {
    state.currentItem = payload.product
  },
  // 聊天记录添加
  addChatList (state, item) {
    const index = item.index
    state.groupList[index].currentname = item.name
    state.groupList[index].currentcontent = item.name + '：' + item.chatcontent
    state.groupList[index].chatList.push(item)
  },
  // 置顶
  setTop (state, item) {
    const index = item.index
    const checkedTop = item.checkedTop
    if (checkedTop) {
      state.groupList.splice(index, 1)
      state.groupList.unshift(state.groupList[index])
    }
  },
  pyp (state, item) {
    const index = item.index
    const newitem = {
      isPyp: true,
      name: item.name
    }
    state.groupList[index].currentcontent = '你拍了拍' + '"' + item.name + '"'
    state.groupList[index].chatList.push(newitem)
  },
  addVisitor (state, item) {
    state.visitorData.push(item)
  },
  addRepair (state, item) {
    state.repairData.push(item)
  },
  addComplain (state, item) {
    state.complainData.push(item)
  }
}

export default mutations
